/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.lcfgly.Interceptor;

import javax.servlet.http.HttpSession;
import org.apache.commons.fileupload.ProgressListener;

/**
 * 上传进度监听器
 * @author lcfgly
 */
public class UploadListener implements ProgressListener{
    
    private HttpSession session;

    public void setSession(HttpSession session) {
        this.session = session;
        UploadStatus status=new UploadStatus();
        session.setAttribute("uploadStatus", status);
    }
    
    
    @Override
    public void update(long pBytesRead, long pContentLength, int pItems) {
        UploadStatus status=(UploadStatus)session.getAttribute("uploadStatus");
        status.setBytesRead(pBytesRead);
        status.setContentLength(pContentLength);
        status.setItems(pItems);
    }
    
}
